package com.peoit.honeycomb.dto;

/**
 *  包括分页信息通用dto
 * Created by Bing.Zeng on 2015/9/30.
 */
public class PageCommonResultDto extends CommonResultDto {
    //每页记录条数
    private int pageSize =Config.default_pageSize;
    //当前页码 从1 开始
    private int page = 1;

    //总页数
    private int pages;
    //满足条件记录条数
    private long count;
    //计算出,数据从第几条开始，前台传过来时表示当前页数，后面计算数据
    private int offset = 0;

    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }

    public long getCount() {
        return count;
    }

    public void setCount(long count) {
        if(count%getPageSize()==0){
            setPages((int)(count/getPageSize()));
        }else {
            setPages((int)(count/getPageSize()+1));
        }
        this.count = count;
    }

    public int getPage() {
        return page;
    }

    public void setPage(int page) {
        this.page = page;
    }

    public int getOffset() {
        return offset;
    }

    public void setOffset(int offset) {
        this.setPage(offset);
        if(offset==0 || offset ==1){
            this.offset = 0;
        }else {
            this.offset =(offset - 1) * getPageSize();
        }
    }

    public int getPages() {
        return pages;
    }

    public void setPages(int pages) {

        this.pages = pages;
    }
}
